import { Ref } from "vue";

export default function OperationHook(state: { fieldColumn: Ref<Array<SuperTable.TableCoulmnItem | SuperTable.NestTableColumnItem>>; emit: any; drawerOpts: Base.DrawerOpts }) {
  const { emit, drawerOpts, fieldColumn } = state;
  const searchHandle = () => {
    emit("search");
  };
  const resetHandle = () => {
    emit("reset");
  };
  const drawerSubmitHandle = (state: Array<SuperTable.TableCoulmnItem | SuperTable.NestTableColumnItem>) => {
    fieldColumn.value = state;
    drawerOpts.visible = false;
  };
  // 展示自定义列配置
  const showCustomConfigHandle = () => {
    drawerOpts.title = "自定义列表字段";
    drawerOpts.width = "550px";
    drawerOpts.component = "CustomListFields";
    drawerOpts.passData = fieldColumn.value;
    drawerOpts.visible = true;
  };
  return {
    searchHandle,
    resetHandle,
    drawerSubmitHandle,
    showCustomConfigHandle
  };
}
